﻿using Fur.Htx.Core.Entities;
using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using Microsoft.EntityFrameworkCore;

namespace Fur.Htx.Application
{
    public class SystemService : ISystemService, ITransient
    {
        public IRepository<UserInfo> repository { get; set; }
        public SystemService(IRepository<UserInfo> repository)
        {
            this.repository = repository;
        }
        public string GetDescription()
        {
            return "让 .NET 开发更简单，更通用，更流行。";
        }

        public async Task<List<UserInfo>> GetUsers()
        {
            return await repository.AsQueryable().ToListAsync();
        }

        public async Task<UserInfo> GetDetail()
        {
            var user = await repository.Include(a => a.Detail, false).FirstOrDefaultAsync(a => a.Id == 1);
            //var detailId = user.Detail.Id;
            return user;
        }

    }
}